//
//  ReturnView.m
//  BasketballClub
//
//  Created by 孙鸿吉 on 16/1/18.
//  Copyright © 2016年 孙鸿吉. All rights reserved.
//

#import "ReturnView.h"
@interface ReturnView()<UITextViewDelegate>
@property (nonatomic,strong)UILabel *pleaceHoledrText;
@end
@implementation ReturnView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self allViews];
    }
    return self;
}
- (void)allViews
{
    self.navigationView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 64 * LAYOUT_SIZE_HEIGHT)];
    self.navigationView.backgroundColor = ColorHex(0x0d1c38);
    [self addSubview:self.navigationView];

    
    self.title = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2 - (40 * LAYOUT_SIZE), 29 * LAYOUT_SIZE_HEIGHT, 80* LAYOUT_SIZE, 26 * LAYOUT_SIZE_HEIGHT)];
    self.title.text = @"反馈";
    self.title.textAlignment = 1;
    self.title.textColor = [UIColor yellowColor];
    self.title.font = [UIFont systemFontOfSize:17 * LAYOUT_SIZE];
    [self.navigationView addSubview:self.title];
    
    //取消按钮
    self.cancleButton = [[UIButton alloc]initWithFrame:CGRectMake(10 * LAYOUT_SIZE, 29 * LAYOUT_SIZE_HEIGHT, 50 * LAYOUT_SIZE, 26 * LAYOUT_SIZE_HEIGHT)];
    [self.cancleButton setImage:[UIImage imageNamed:@"fanhui"] forState:UIControlStateNormal];
    [self.navigationView addSubview:self.cancleButton];
    
    self.returnTextView = [[UITextView alloc]initWithFrame:CGRectMake(5 * LAYOUT_SIZE, 70 * LAYOUT_SIZE_HEIGHT, SCREEN_WIDTH - 10 * LAYOUT_SIZE, 100 * LAYOUT_SIZE_HEIGHT)];
    self.returnTextView.layer.borderWidth = 1;
    self.returnTextView.layer.borderColor = [UIColor lightGrayColor].CGColor;
    self.returnTextView.layer.masksToBounds = YES;
    self.returnTextView.layer.cornerRadius = 5;
    self.returnTextView.delegate = self;
    self.returnTextView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    [self addSubview:self.returnTextView];
    
    self.pleaceHoledrText = [[UILabel alloc]initWithFrame:CGRectMake(5 * LAYOUT_SIZE, 5 * LAYOUT_SIZE_HEIGHT, SCREEN_WIDTH - 20 * LAYOUT_SIZE, 25 * LAYOUT_SIZE_HEIGHT)];
    self.pleaceHoledrText.text = @"请输入您的宝贵意见...";
    self.pleaceHoledrText.textColor = [UIColor lightGrayColor];
    self.pleaceHoledrText.font = [UIFont systemFontOfSize:16 * LAYOUT_SIZE];
    self.pleaceHoledrText.textAlignment = 0;
    self.pleaceHoledrText.backgroundColor = [UIColor clearColor];
    self.pleaceHoledrText.enabled = NO;
    [self.returnTextView addSubview:self.pleaceHoledrText];
    
    self.sendButton = [[UIButton alloc]initWithFrame:CGRectMake(SCREEN_WIDTH - (60 * LAYOUT_SIZE), 29 * LAYOUT_SIZE, 50 * LAYOUT_SIZE, 26 * LAYOUT_SIZE)];
    [self.sendButton setTitle:@"发送" forState:UIControlStateNormal];
    self.sendButton.titleLabel.font = [UIFont systemFontOfSize:17 * LAYOUT_SIZE];
    [self.sendButton setTitleColor:[UIColor yellowColor] forState:UIControlStateNormal];
    [self.navigationView addSubview:self.sendButton];
    
}
- (void)textViewDidBeginEditing:(UITextView *)textView
{
    self.pleaceHoledrText.text = @"";
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self endEditing:YES];
    if (self.returnTextView.text.length == 0) {
        self.pleaceHoledrText.text = @"请输入您的宝贵意见...";
    }
    
}
@end
